<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>uupaa-event.js - uuClass.Event.handler</title>
<style type="text/css">@import url(../README.css);</style>
<style>#result { background-color: green; }</style>
<script type="text/javascript" src="http://uupaa-js-spinoff.googlecode.com/svn/trunk/uupaa-detect.js/uupaa-detect.mini.js"></script>
<script type="text/javascript" src="../uupaa-event.js"></script>
</head>
<body>
<div id="clicktarget" style="border: 1px solid red">clicktarget<br />click this area</div>
<div id="result"></div>
<script type="text/javascript">
function boot() {
  var MyClass = function(element) {
    uu.event.attach(element, "click", this);
  };
  MyClass.prototype.handleEvent = function(evt) {
    var mpos = uu.event.stop(evt).mouse(evt);
    document.getElementById("result").innerHTML = "x=" + mpos.x + ", y=" + mpos.y;
  };
  var my = new MyClass(document.getElementById("clicktarget"));
}
window.onload = boot;
</script>
<pre class="eg" id="example">
var MyClass = function(element) {
  <u>// クリックイベントをアタッチ</u>
  <b>uu.event.attach</b>(element, "click", this);
};
MyClass.prototype.<b>handleEvent</b> = function(evt) { <u>// 第一引数にイベントオブジェクトが渡される</u>
  <u>// イベントバブルを停止しマウス座標を取得</u>
  var mpos = <b>uu.event.stop</b>(evt).<b>mouse</b>(evt);
  document.getElementById("result").innerHTML = "x=" + mpos.x + ", y=" + mpos.y;
};
var my = new MyClass(document.getElementById("clicktarget"));
</pre>
</body></html>
